home *** CD-ROM | disk | FTP | other *** search
- /* SETBLOCK.C --- p. 658 */
- #include <stdio.h>
- #include <dos.h>
- #include <mem.h>
- #define DOS_PRTSTR 9
- char str[80] = "Test allocmem...\n$";
- main()
- {
- union REGS xr;
- struct SREGS sr;
- char far *stradd;
- unsigned int segadd, maxsize;
- stradd = (char far *)(&str[0]);
- if(allocmem(1, &segadd) != -1)
- {
- printf("Memory allocation failed!\n");
- exit(0);
- }
- if((maxsize = setblock(segadd, 5)) == -1)
- {
- printf("setblock failed!\n");
- printf("Maximum size possible = %d paragraphs\n", maxsize);
- exit(0);
- }
- /* Use movedata to copy the string to allocated memory */
- movedata(FP_SEG(stradd), FP_OFF(stradd), segadd, 0, 80);
- sr.ds = segadd;
- xr.x.dx = 0;
- xr.h.ah = DOS_PRTSTR;
- intdosx(&xr, &xr, &sr);
- /* Free memory before exiting */
- freemem(segadd);
- }